<?php

namespace app\land\utils;

trait JsonResponse
{
    public function success($msg = 'success' , $data = []){
        return $this->baseResponse(200 , $msg , $data);
    }

    public function error($msg = '' , $code = 404){
        return $this->baseResponse($code , $msg);
    }

    public function baseResponse($code , $msg = '' , $data = []){
        return json([
            'code' => $code ,
            'msg' => $msg ,
            'data' => $data ,
        ]);
    }
}